package com.xumz.dao.impl;

import java.util.List;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import com.xumz.controller.tool.IDFactoty;
import com.xumz.dao.StudentDao;
import com.xumz.model.Student;
@Repository
public class StudentDaoImpl extends SqlSessionDaoSupport implements StudentDao {
	@Override
	public List<Student> selectStudent() {
		List<Student> list = this.getSqlSession().selectList("findAllStudent");
		return list;
	}
	
	@Override
	public Student selectOne(String id) {
		Student student =this.getSqlSession().selectOne(this.getClass().getName() + ".findStudentById",id);
		return student;
	}
	
	@Override
	public int stumembersadd(String stuname,String blogurl,String classoption) {
		Student student = new Student(IDFactoty.productIdByDateTime(), classoption, stuname, blogurl);
		return this.getSqlSession().insert(this.getClass().getName() + ".stumembersadd", student);
	}

	@Override
	public int stuinformationUpdate(Student student){
		return this.getSqlSession().update(this.getClass().getName() + ".stuinformationupdate", student);
	}
	
	@Override
	public int bloginformationUpdate(Student student){
		return this.getSqlSession().update(this.getClass().getName() + ".bloginformationupdate", student);
	}
	
	@Override
	public int classinformationUpdate(Student student){
		return this.getSqlSession().update(this.getClass().getName() + ".classinformationupdate", student);
	}
	
	@Override
	public List<Student> selectStudentByClassId(String id){
		List<Student> list = this.getSqlSession().selectList(this.getClass().getName() + ".findStudentByClassId", id);
		return list;
	}
	
	@Override
	public int stumemberDelete(String id){
		return this.getSqlSession().delete(this.getClass().getName() + ".stumemberDelete", id);
	}

	@Override
	public int studentUpdateNum(Student student) {
		return this.getSqlSession().update(this.getClass().getName() + ".studentUpdateNum", student);
	}
}
